package com.example.demo.msg.aio.client;

import java.util.Scanner;

public class AioClient {

    private static  ClientHandler clientHandler;

    public static void start(){
        if(clientHandler != null)
            return;

        clientHandler = new ClientHandler(8888,"127.0.0.1");

        new Thread(clientHandler).start();

    }

    public static boolean sendMsg(String msg){
        if("q".equals(msg)) return false;

        clientHandler.sendMsg(msg);
        return true;
    }

    public static void main(String[] args) {
        AioClient.start();

        while (AioClient.sendMsg(new Scanner(System.in).nextLine()));
    }
}